#pragma once
#include <string>
#include "Poco\Crypto\Cipher.h"
#include "Poco\Crypto\CipherKey.h"
#include "Poco\Crypto\CipherFactory.h"
using Poco::Crypto::Cipher;
using Poco::Crypto::CipherKey;
using Poco::Crypto::CipherFactory;

namespace Poco {
	class File;
	class Path;
	class Logger;
	namespace Util {
		class Application;
		class LayeredConfiguration;
	}
}


class Cryptoer
{
public:
	Cryptoer();
	virtual ~Cryptoer();
	std::string encodeContents(const std::string &fn);
	std::string decodeContents(const std::string &fn);
	std::string encodeContents(const Poco::File &f);
	std::string decodeContents(const Poco::File &f);
	std::string rawDecode(const std::string &contents);
	std::string rawEncode(const std::string &contents);
	std::string rawDecodeNonBase64(const std::string &contents);
	std::string rawEncodeNonBase64(const std::string &contents);
	void rawDecodeNonBase64(std::istream& source, std::ostream& sink);
	void rawEncodeNonBase64(std::istream& source, std::ostream& sink);
	void encodeFile(const std::string &ifn,const std::string &ofn);
	void decodeFile(const std::string &ifn,const std::string &ofn);
	void encodeFile(const std::string &ifn);
	void decodeFile(const std::string &ifn);
	void encodeFile(const Poco::File &ifn);
	void decodeFile(const Poco::File &ifn);
	virtual std::string encodeContents(std::string contents, std::string file_base, std::string file_ext)=0;
	virtual std::string decodeContents(std::string contents, std::string file_base, std::string file_ext)=0;
	virtual void showInfo() = 0;
private:

protected:
	std::string replaceAll(const std::string& str, const std::string& from, const std::string& to);
	std::string processGlobalMacro(std::string raw, std::string file_base, std::string file_ext);
	std::string crypto;
	std::string pwd;
	Cipher::Ptr pCipher;

};

